<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/10
 * Time: 10:16
 */

namespace app\redis\controller;


use think\App;
use think\Controller;
use think\Request;

class Key extends Controller
{
    private $redis;

    public function __construct(App $app = null)
    {
        parent::__construct($app);
        $this->redis = new \Redis();
        $this->redis->connect('127.0.0.1',6379);
    }

    /**
     * 删除一个在string中设置好的key
     */
    public function del(Request $request)
    {
        $key = $request->param('key');
        $value = $this->redis->del("$key");
        return $value; //返回的是删除的key的数量
    }
}